﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Threading;
using MCB.Net.Protocol;

namespace MCB.Net.Server
{
    public class TcpConnection
    {
        public string Id { get; private set; }

        internal Socket Socket { get; set; }

        public IProtocol Protocol { get; set; }

        public byte[] InitBuffer { get; set; }

        public int InitPosition { get; set; }

        public TcpConnection()
        {
            Id = CreateId();
            InitBuffer = new byte[200];
        }

        protected string CreateId()
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(DateTime.Now.Ticks);
            builder.Append(Thread.CurrentThread.ManagedThreadId);
            return builder.ToString();
        }

    }
}
